package com.cskaoyan.wordmemorize.config;

import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.openai.OpenAiChatModel;
import org.springframework.ai.openai.api.OpenAiApi;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AIConfig {
//    @Bean
//    public ChatClient chatClient() {
//        OpenAiApi openAiApi = new OpenAiApi("sk-edb2271d98f349399e9dd48077ddce62");
//        OpenAiChatModel chatModel = new OpenAiChatModel(openAiApi);
//        return ChatClient.builder(chatModel).build();
//    }


    // Spring自动注入ChatClient.Builder对象

    @Bean
    public ChatClient chatClient(ChatClient.Builder chatClientBuilder) {
        // 利用Builder对象的build()方法创建出ChatClient对象
       return chatClientBuilder.build();
    }
}

